home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / sscanf.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  942b  |  57 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "lib.h"
  4.  
  5. static int sgetc __PROTO((FILE *s));
  6. static int sungetc __PROTO((int c, FILE *s));
  7.  
  8. static int sgetc(s)
  9.     FILE *s;
  10. {
  11.     register unsigned char c;
  12.  
  13.     c = *(*(unsigned char **) s)++;
  14.     return((c == '\0') ? EOF : c);
  15. }
  16.  
  17. static int sungetc(c, s)
  18.     int c;
  19.     FILE *s;
  20. {
  21.     --(*(unsigned char **) s);
  22.     return c;
  23. }
  24.  
  25. #ifdef __STDC__
  26. int sscanf(const char *buf, const char *fmt, ...)
  27. {
  28.     int retval;
  29.     va_list args;
  30.     
  31.     va_start (args, fmt);
  32.     retval = _scanf((FILE *)&buf, sgetc, sungetc, fmt, args);
  33.     va_end (args);
  34.     return retval;
  35. }
  36. #else
  37. int
  38. sscanf(buf, fmt, arg)
  39.     const char *buf, *fmt;
  40.     int arg;
  41. {
  42.     return(_scanf(&buf, sgetc, sungetc, fmt, &arg));
  43. }
  44. #endif /* __STDC__ */
  45.  
  46. #ifdef __STDC__
  47. int vsscanf(const char *buf, const char *fmt, va_list arg)
  48. #else
  49. int
  50. vsscanf(buf, fmt, arg)
  51.     const char *buf, *fmt;
  52.     char *arg;
  53. #endif /* __STDC__ */
  54.     {
  55.     return(_scanf((FILE *)&buf, sgetc, sungetc, fmt, arg));
  56.     }
  57.